import { MiddlewareConsumer, Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { TypeOrmModule } from '@nestjs/typeorm';

import { APP_GUARD } from '@nestjs/core';
import { StatusMonitorModule } from 'nest-status-monitor';
import { configModule } from './utils/config/config.module';
import { JwtAuthGuard } from './utils/guard/auth.guard';
import CommonConfig from './utils/config/env/common';
import { LargeModelModule } from './large-model/large-model.module';
import { ConfigService } from '@nestjs/config';
import { AuthModule } from './auth/auth.module';
import { PromptModule } from './prompt/prompt.module';
import { QuestionModule } from './question/question.module';
import { InformationModule } from './information/information.module';
import { UploadModule } from './upload/upload.module';
import { UserInfoModule } from './userInfo/userinfo.module';
import { TagModule } from './tag/tag.module';
import { ChatMessageModule } from './chatMessage/chatMessage.module';
import { SessionModule } from './session/session.module';
import { MongooseModule } from '@nestjs/mongoose';
@Module({
  imports: [
    //NOTE(@date:2023-04-26 09:54:13 谭人杰): 9、添加服务监控
    StatusMonitorModule.setUp(CommonConfig.statusMonitorConfig),
    //NOTE(@date:2023-12-29 16:57:52 谭人杰): 9、添加mongoDB
    MongooseModule.forRootAsync({
      imports: [configModule],
      inject: [ConfigService],
      useFactory: (configService: ConfigService) => {
        const config = configService.get('mongo')
        return {
          uri: `mongodb://${config.username}:${config.password}@${config.host}:${config.port}/${config.database}?authSource=admin`
        };
      },
    }),
    //NOTE(@date:2023-04-17 17:18:52 谭人杰): 8、添加mysql
    TypeOrmModule.forRootAsync({
      //NOTE(@date:2023-04-18 13:58:39 谭人杰): 7、引入配置文件
      imports: [configModule],
      inject: [ConfigService],
      useFactory: (configService: ConfigService) => {
        return configService.get('mysql');
      },
    }),
    LargeModelModule,
    AuthModule,
    //NOTE(@date:2024-1-2 10:56:52 陈谦): 添加prompt公共配置
    PromptModule,
    //NOTE(@date:2024-1-2 10:56:52 陈谦): 添加问答对
    QuestionModule,
    //NOTE(@date:2024-1-3 18:56:52 陈谦): 添加情报管理
    InformationModule,
    //NOTE(@date:2024-1-3 12:56:52 陈谦): 添加情文件上传
    UploadModule,
    //NOTE(@date:2024-1-4 12:56:52 陈谦): 添加用户管理
    UserInfoModule,
    //NOTE(@date:2024-1-4 14:04:52 陈谦): 添加标签管理
    TagModule,
    //NOTE(@date:2024-1-5 18:10:52 陈谦): 添加聊天
    ChatMessageModule,
    //NOTE(@date:2024-1-5 18:10:52 陈谦): 添加session
    SessionModule
  ],
  controllers: [AppController],
  providers: [
    AppService,
    {
      provide: APP_GUARD,
      useClass: JwtAuthGuard,
    },
  ],
})
export class AppModule {
  // eslint-disable-next-line @typescript-eslint/no-empty-function
  configure(consumer: MiddlewareConsumer) {}
}
